package cn.stu.lqj.demo.serviceImpl;

import cn.stu.lqj.demo.mapper.DeptMapper;
import cn.stu.lqj.demo.mapper.EmpMapper;
import cn.stu.lqj.demo.pojo.All;
import cn.stu.lqj.demo.pojo.Dept;
import cn.stu.lqj.demo.pojo.Emp;
import cn.stu.lqj.demo.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;

@Service
public class DeptServiceImpl implements DeptService {
    @Autowired(required = false)
    private DeptMapper deptMapper;
    @Autowired(required = false)
    private EmpMapper empMapper;
//    @Override
//    public String findDetailById(Integer empId, Model model) {
//        Dept dept = deptMapper.selectById(empId);
//        model.addAttribute("dept", dept);
//        return "findDetailById";
//    }

    public String findDetailById(Integer id, Model model) {
        Emp emp = empMapper.selectById(id);
        Dept dept = deptMapper.selectById(emp.getEmpId());
        All all=new All().setId(emp.getId()).setName(emp.getName())
                .setCardId(emp.getCardId()).setAge(emp.getAge())
                .setSalary(emp.getSalary()).setEmpId(emp.getEmpId())
                .setDeptName(dept.getDeptName())
                .setDeptLoc(dept.getDeptLoc()).setDeptNum(dept.getDeptNum());
        model.addAttribute("all", all);
        return "findDetailById";
    }
}
